# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=s5cmd
pkgver=2.2.2
pkgrel=0
pkgdesc="Parallel S3 and local filesystem execution tool"
url="https://github.com/peak/s5cmd"
arch="all"
license="MIT"
makedepends="go"
checkdepends="shared-mime-info"
source="$pkgname-$pkgver.tar.gz::https://github.com/peak/s5cmd/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local goldflags="
	-X github.com/peak/s5cmd/v2/version.Version=v$pkgver
	-X github.com/peak/s5cmd/v2/version.GitCommit=AlpineLinux
	"
	go build -v -o bin/$pkgname -ldflags "$goldflags"
}

check() {
	# TestAppProxy sometimes fails to spawn a local HTTP server
	S5CMD_BUILD_BINARY_WITHOUT_RACE_FLAG=1 \
		go test -skip TestAppProxy ./...
}

package() {
	install -Dm755 bin/$pkgname "$pkgdir"/usr/bin/$pkgname
}

sha512sums="
8a9ae4247c41a63d41556d259af3093584b712330571c5997f6d41dd2731c01295bf51188cf3aa0a58fbdb4e8f2c7162a0e6bca13f5f716b6f267000a77289c1  s5cmd-2.2.2.tar.gz
"
